package view.interfaces;

import java.awt.Color;
import java.awt.Component;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JTable;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;

public class telaAdministrador extends JFrame {
	private JTable table;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					telaAdministrador frame = new telaAdministrador();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public telaAdministrador() {
		setTitle("Administrador");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 800, 514);
		JPanel contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);

		JLabel lblOlAdministrador = new JLabel("Ol\u00E1 Administrador!");
		lblOlAdministrador
				.setIcon(new ImageIcon(
						"C:\\Users\\Michael\\Documents\\Faculdade\\Plano de Ensino - Disciplina Projeto Interativo IV\\Projeto Pizzaria\\Pizzaria\\src\\tumblr_lln52xMpNv1qab04f.gif"));
		lblOlAdministrador.setForeground(Color.RED);
		lblOlAdministrador
				.setFont(new Font("Traditional Arabic", Font.BOLD, 20));

		JButton btnNewButton = new JButton("VOLTAR");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				new telaPrincipal().setVisible(true);
				setVisible(false);
			}
		});
		btnNewButton.setFont(new Font("Tahoma", Font.BOLD, 12));

		JPanel panel = new JPanel();
		panel.setBorder(new LineBorder(new Color(0, 0, 0)));

		table = new JTable();
		table.setBorder(new LineBorder(new Color(0, 0, 0)));
		GroupLayout gl_contentPane = new GroupLayout(contentPane);
		gl_contentPane.setHorizontalGroup(gl_contentPane
				.createParallelGroup(Alignment.TRAILING)
				.addGroup(
						gl_contentPane
								.createSequentialGroup()
								.addComponent(lblOlAdministrador,
										GroupLayout.DEFAULT_SIZE, 656,
										Short.MAX_VALUE).addGap(18)
								.addComponent(btnNewButton).addGap(19))
				.addGroup(
						Alignment.LEADING,
						gl_contentPane
								.createSequentialGroup()
								.addComponent(panel,
										GroupLayout.PREFERRED_SIZE, 212,
										GroupLayout.PREFERRED_SIZE)
								.addPreferredGap(ComponentPlacement.UNRELATED)
								.addComponent(table, GroupLayout.DEFAULT_SIZE,
										552, Short.MAX_VALUE)));
		gl_contentPane
				.setVerticalGroup(gl_contentPane
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								gl_contentPane
										.createSequentialGroup()
										.addGroup(
												gl_contentPane
														.createParallelGroup(
																Alignment.LEADING)
														.addGroup(
																gl_contentPane
																		.createSequentialGroup()
																		.addContainerGap()
																		.addComponent(
																				btnNewButton))
														.addComponent(
																lblOlAdministrador,
																GroupLayout.PREFERRED_SIZE,
																71,
																GroupLayout.PREFERRED_SIZE))
										.addGroup(
												gl_contentPane
														.createParallelGroup(
																Alignment.LEADING)
														.addGroup(
																gl_contentPane
																		.createSequentialGroup()
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addComponent(
																				panel,
																				GroupLayout.DEFAULT_SIZE,
																				389,
																				Short.MAX_VALUE))
														.addGroup(
																gl_contentPane
																		.createSequentialGroup()
																		.addGap(7)
																		.addComponent(
																				table,
																				GroupLayout.DEFAULT_SIZE,
																				388,
																				Short.MAX_VALUE)))));

		JButton btnNewButton_2 = new JButton("Estoque");
		btnNewButton_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				telaAddEstoque frame = new telaAddEstoque();
				frame.setVisible(true);
				frame.listarcombo();
				setVisible(false);
			}
		});

		JButton btnNewButton_1 = new JButton("Produtos");
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				new telaProdutos().setVisible(true);
				setVisible(false);
			}
		});

		JButton btnNewButton_3 = new JButton("Pizzas");
		btnNewButton_3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				ListarPizzas listarPizzas = new ListarPizzas();
				listarPizzas.frmPizza.setVisible(Boolean.TRUE);
				setVisible(Boolean.FALSE);
			}
		});

		JButton btnNewButton_4 = new JButton("Cadastro de Usu\u00E1rio");
		btnNewButton_4.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				telaCadastroUsuario cadastroUsuario = new telaCadastroUsuario();
				cadastroUsuario.listar();
				cadastroUsuario.setVisible(true);
				setVisible(false);
			}
		});

		JButton btnRelatrioDeVendas = new JButton("Relat\u00F3rio de Vendas");

		JButton btnRelatrioDeEstoque = new JButton("Relat\u00F3rio de Estoque");
		GroupLayout gl_panel = new GroupLayout(panel);
		gl_panel.setHorizontalGroup(gl_panel
				.createParallelGroup(Alignment.LEADING)
				.addGroup(
						gl_panel.createSequentialGroup()
								.addGap(14)
								.addGroup(
										gl_panel.createParallelGroup(
												Alignment.LEADING)
												.addComponent(
														btnNewButton_1,
														GroupLayout.PREFERRED_SIZE,
														185,
														GroupLayout.PREFERRED_SIZE)
												.addComponent(btnNewButton_2)
												.addComponent(btnNewButton_3)
												.addComponent(btnNewButton_4)
												.addComponent(
														btnRelatrioDeVendas,
														GroupLayout.PREFERRED_SIZE,
														185,
														GroupLayout.PREFERRED_SIZE)
												.addComponent(
														btnRelatrioDeEstoque,
														GroupLayout.PREFERRED_SIZE,
														185,
														GroupLayout.PREFERRED_SIZE))
								.addContainerGap(13, Short.MAX_VALUE)));
		gl_panel.setVerticalGroup(gl_panel.createParallelGroup(
				Alignment.LEADING).addGroup(
				gl_panel.createSequentialGroup()
						.addGap(18)
						.addComponent(btnNewButton_1,
								GroupLayout.PREFERRED_SIZE, 54,
								GroupLayout.PREFERRED_SIZE)
						.addGap(5)
						.addComponent(btnNewButton_2)
						.addPreferredGap(ComponentPlacement.RELATED)
						.addComponent(btnNewButton_3)
						.addPreferredGap(ComponentPlacement.RELATED)
						.addComponent(btnNewButton_4)
						.addPreferredGap(ComponentPlacement.RELATED)
						.addComponent(btnRelatrioDeVendas,
								GroupLayout.PREFERRED_SIZE, 54,
								GroupLayout.PREFERRED_SIZE)
						.addPreferredGap(ComponentPlacement.RELATED)
						.addComponent(btnRelatrioDeEstoque,
								GroupLayout.PREFERRED_SIZE, 54,
								GroupLayout.PREFERRED_SIZE)
						.addContainerGap(18, Short.MAX_VALUE)));
		gl_panel.linkSize(SwingConstants.VERTICAL, new Component[] {
				btnNewButton_2, btnNewButton_1, btnNewButton_3, btnNewButton_4,
				btnRelatrioDeVendas, btnRelatrioDeEstoque });
		gl_panel.linkSize(SwingConstants.HORIZONTAL, new Component[] {
				btnNewButton_2, btnNewButton_1, btnNewButton_3, btnNewButton_4,
				btnRelatrioDeVendas, btnRelatrioDeEstoque });
		panel.setLayout(gl_panel);
		contentPane.setLayout(gl_contentPane);
	}

	private static void addPopup(Component component, final JPopupMenu popup) {
		component.addMouseListener(new MouseAdapter() {
			public void mousePressed(MouseEvent e) {
				if (e.isPopupTrigger()) {
					showMenu(e);
				}
			}

			public void mouseReleased(MouseEvent e) {
				if (e.isPopupTrigger()) {
					showMenu(e);
				}
			}

			private void showMenu(MouseEvent e) {
				popup.show(e.getComponent(), e.getX(), e.getY());
			}
		});
	}
}
